package org.bdware.doip.core.codec.packet;

import io.netty.channel.ChannelHandlerContext;
import org.bdware.doip.core.doipMessage.MessageEnvelope;
import org.bdware.doip.core.exception.EnvelopeResendException;

import java.util.ArrayList;

public abstract class AbstractEnvelopeReceiveBuffer {
    public int requestId;


    public AbstractEnvelopeReceiveBuffer(int requestId){
        this.requestId = requestId;
    }


    public abstract boolean isCompleted();

    /**
     *  Add a new envelope into buffer
     * @param envelope new MessageEnvelope
     * Return  (expected totalNumber) - (buffered envelope number);
     */
    public abstract int addEnvelope(MessageEnvelope envelope) throws EnvelopeResendException;

    /**
     * Return the full sorted envelopes
     */
    public abstract ArrayList<MessageEnvelope> getSortedEnvelopes();

}
